<!DOCTYPE html>
<html lang="en" style="background:#fff;">
<head>
    <base href="${basePath}">
    <#include "common/top.html"/>
</head>
<body style="background:#fff;">
<style>
    .layui-form-select dl {
        width: 200px;
    }

</style>
<form class="layui-form" modelAttribute="role" name="form1" id="form1" method="post">
    <input type="hidden" name="roleId" id="roleId" value="${sysRole.roleId}"/>
    <div class="layui-form-item layui-form-item-dialog">
        <label class="layui-form-label"><span style="color: red;">*</span>中文名称：</label>
        <div class="layui-input-inline">
            <input class="layui-input" type="text" name="roleName" id="roleName" placeholder="请输入名称"
                   value="${sysRole.roleName}"/>
        </div>
    </div>
    <div class="layui-form-item layui-form-item-dialog">
        <label class="layui-form-label"><span style="color: red;">*</span>英文名称：</label>
        <div class="layui-input-inline">
            <input class="layui-input" type="text" name="roleCode" <#if roleId??> readonly="readonly"  </#if>  id="roleCode" placeholder="请输入角色编码"
                   value="${sysRole.roleCode}"/>
        </div>
    </div>

    <!-- 如果不是银行管理员或者超级管理员 ,不显示机构 -->
    <#if roleflag=='1'>
    <div class="layui-form-item layui-form-item-dialog">
        <label class="layui-form-label"><span style="color: red;">*</span>企业名称:</label>
        <div class="layui-input-inline">
            <select id="comCode" name="comCode" lay-filter="comCode" lay-verify="" lay-search>
                <option value="">--请选择--</option>
                <#list comInfoList?if_exists as comInfo >
                    <option value="${comInfo.comCode}">${comInfo.comName}</option>
                </#list>
            </select>
        </div>
    </div>
     <#else>
           <div class="layui-form-item layui-form-item-dialog">
               <label class="layui-form-label"><span style="color: red;">*</span>企业名称:</label>
               <div class="layui-input-inline">
                   <select id="comCode" name="comCode" lay-filter="comCode" lay-verify="" lay-search>
                       <option value="${comInfo.comCode}">${comInfo.comName}</option>
                   </select>
               </div>
           </div>
    </#if>
    <div class="layui-form-item layui-form-item-dialog">
        <label class="layui-form-label">备注：</label>
        <div class="layui-input-inline">
            <input class="layui-input" type="text" name="remarks" id="remarks" placeholder="请输入备注信息"
                   value="${sysRole.remarks}"/>
        </div>
    </div>
</form>
</body>
<script type="text/javascript">

    var $form;
    var form;
    layui.use(['form', 'layedit', 'laydate'], function () {
        form = layui.form();
        debugger;
        $("#comCode option").each(function () {
            if ($(this).val() == "${sysRole.comCode}") {
                $(this).attr("selected", true);
            }
        });
        form.render();
    });
    //保存
    function save() {
        if (checkIsNull("roleName", "请输入角色名称") || checkIsNull("roleCode", "请输入角色编码")) {
            return false;
        }


       var userid = "${rolef}";

        /**
         * 如果不是超级管理员权限
         */
       if(userid!="admin"){
           if( checkIsNull("comCode","请选择企业名称")){
                 return false;
           }
       }


        $.ajax({
            url: "${basePath}/sysuser/role/saveUpdateRole",
            data: $("#form1").serialize(),
            type: "POST",
            success: function (data) {
                if (data.status == 'success') {
                    parent.layer.alert(data.msg, function (index) {
                        var index1 = parent.layer.getFrameIndex(window.name); //获取窗口索引
                        parent.layer.close(index1);
                        parent.layer.close(index);
                    });
                } else {
                    parent.layer.alert(data.msg);
                }
            }
        })
    }
</script>
</html>


